package ar.edu.unlam.tpfinal.struts.forms;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.collections.Factory;
import org.apache.commons.collections.ListUtils;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;

@SuppressWarnings("serial")
public class ClientAddressForm extends ActionForm {
	
	private ClientForm client = null;
	
	private List<AddressForm> addressList = null;
	
	public ClientAddressForm() {
		client = new ClientForm();
		addressList = new ArrayList<AddressForm>();
	}

	public ClientForm getClient() {
		return client;
	}

	public void setClient(ClientForm client) {
		this.client = client;
	}

	public List<AddressForm> getAddressList() {
		return addressList;
	}

	public void setAddressList(List<AddressForm> addressList) {
		this.addressList = addressList;
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public void reset(ActionMapping actionMapping, HttpServletRequest httpServletRequest) {
		addressList = (List<AddressForm>) 
						ListUtils.lazyList(new ArrayList<Object>(), new Factory() {
				            public Object create() {
				                return new AddressForm();
				            }
			        	});
    }
	
}
